/*
 * Connection.h
 *
 *  Created on: Aug 12, 2012
 *      Author: nam20485
 */

#ifndef CONNECTION_H_
#define CONNECTION_H_


#include "IConnector.h"

class Connection
{
public:
	typedef enum
	{
		SUCCESS,
		FAIL
	} RESPONSE;

	typedef long ID;
	//typedef void (*ConnectionReceiveHandler)(ID lClientID, const Message& message);

	Connection(ID lID, IConnector& connector/*, ConnectionReceiveHandler pfnConnectionReceiveHandler*/);
	virtual ~Connection();

	RESPONSE Connect();
	RESPONSE Disconnect();

	RESPONSE Send(const Message& message) const;
	const Message* Receive() const;

	inline ID getID() const	{ return m_lID; }

protected:
	const ID m_lID;
	//const ConnectionReceiveHandler m_pfnReceiveHandler;
	IConnector& m_connector;

	void OnConnectorReceiveHandler(const Message& message);
};

#endif /* CONNECTION_H_ */
